package com.ruoyi.system.service.impl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.system.domain.RnxRoster;
import com.ruoyi.system.mapper.RnxRosterMapper;
import com.ruoyi.system.service.IRnxRosterService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 员工花名册Service业务层处理
 *
 * @author ruoyi
 * @date 2022-04-28
 */
@Service
public class RnxRosterServiceImpl implements IRnxRosterService {
	@Resource
	private RnxRosterMapper rnxRosterMapper;

	/**
	 * 查询员工花名册
	 *
	 * @param id 员工花名册主键
	 * @return 员工花名册
	 */
	@Override
	public RnxRoster selectRnxRosterById(Long id) {
		return rnxRosterMapper.selectRnxRosterById(id);
	}

	/**
	 * 查询员工花名册列表
	 *
	 * @param rnxRoster 员工花名册
	 * @return 员工花名册
	 */
	@Override
	public List<RnxRoster> selectRnxRosterList(RnxRoster rnxRoster) {
		return rnxRosterMapper.selectRnxRosterList(rnxRoster);
	}

	/**
	 * 新增员工花名册
	 *
	 * @param rnxRoster 员工花名册
	 * @return 结果
	 */
	@Override
	public int insertRnxRoster(RnxRoster rnxRoster) {
		//生成序号
		Long i = rnxRosterMapper.findMaxSerialNumber();
		//设置默认值
		if(i == null)i = 1L;
		rnxRoster.setSerialNumber(i+1);
		return rnxRosterMapper.insertRnxRoster(rnxRoster);
	}

	/**
	 * 修改员工花名册
	 *
	 * @param rnxRoster 员工花名册
	 * @return 结果
	 */
	@Override
	public int updateRnxRoster(RnxRoster rnxRoster) {
		return rnxRosterMapper.updateRnxRoster(rnxRoster);
	}

	/**
	 * 批量删除员工花名册
	 *
	 * @param ids 需要删除的员工花名册主键
	 * @return 结果
	 */
	@Override
	public int deleteRnxRosterByIds(String ids) {
		return rnxRosterMapper.deleteRnxRosterByIds(Convert.toStrArray(ids));
	}

	/**
	 * 删除员工花名册信息
	 *
	 * @param id 员工花名册主键
	 * @return 结果
	 */
	@Override
	public int deleteRnxRosterById(Long id) {
		return rnxRosterMapper.deleteRnxRosterById(id);
	}

	@Override
	public RnxRoster selectRnxRosterByPhone(String inviteCode) {
		return rnxRosterMapper.selectRnxRosterByPhone(inviteCode);
	}
}
